<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- <button class="a">按钮1</button>
    <button class="a">按钮2</button> -->
    <!-- <img src="http://img.jk51.com/img_jk51/18258208.jpeg" alt="">
    <img src="http://img1.imgtn.bdimg.com/it/u=2651160566,1721233170&fm=214&gp=0.jpg" alt="">
    <img src="http://pic.616pic.com/bg_w1180/00/15/30/yQNuh6fhGg.jpg" alt="">
    <img src="http://pic1.16pic.com/00/55/22/16pic_5522709_b.jpg" alt=""> -->
    <form>
        <input type="checkbox" name="" id="all" onclick="selectAll();" />全选<br />
        <hr /><br />
        <input class="chk" type="checkbox" name="chk" onclick="selectSingle();" />菜单一<br /><br />
        <input class="chk" type="checkbox" name="chk" onclick="selectSingle();" />菜单二<br /><br />
        <input class="chk" type="checkbox" name="chk" onclick="selectSingle();" />菜单三<br /><br />
        <input class="chk" type="checkbox" name="chk" onclick="selectSingle();" />菜单四<br /><br />
    </form>
    <script type="text/javascript" >
        var dom=document.getElementById('all');
        var doms=document.getElementsByName('chk');
        function selectAll(){
            var len = doms.length;
            for(var i=0;i<len;i++){
                if(dom.checked){
                    doms[i].checked=true;
                }else{
                    doms[i].checked=false;
                };
            }
        };
        function selectSingle(){
            let len = 0;
            let count = doms.length;
            for(var i=0;i<count;i++){
                if(doms[i].checked==true){
                    len++;
                }
            }
            if (count == len) {
                dom.checked = true;
            }else{
                dom.checked = false;
            }
        }
    </script>
</body>
<script>
    // var a=document.querySelectorAll(".a");
    // for(i=0;i<a.length;i++){
    //     a[i].onclick=function(){
    //         console.log(1);
    //     }
    // }
    // a.onclick=function(){
    //     console.log(1);
    // }
    var a=0;
    var str;
    for(var i=0;i<3;i++){
        str=a;
        str++;
        a=str;
    }
    console.log(str);
</script>
</html>